package com.nakaikensuke.tools;

import android.webkit.MimeTypeMap;

public class MimeUtilities {
	public static String getMimeType(String fileName) {
		String extension = getExtension(fileName).toLowerCase();
		return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
	}
	
	private static String getExtension(String fileName) {
		if(fileName == null)
			return null;
		
		int position = fileName.lastIndexOf(".");
		if(position == -1)
			return fileName;
		
		return fileName.substring(position + 1);
	}
}
